package com.test.web.controller.base;

import com.he.web.util.Webs;
import com.test.web.config.CustomConfig;
import com.test.web.entity.Backuser;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;

/**
 * @author heyanjing
 * date:2020-07-01 2020/7/1:13:56
 */
@Slf4j
@Data
public class BaseController {

    @Autowired
    private CustomConfig customConfig;
    private Backuser     backuser;

    @ModelAttribute
    public void setReqAndRes(HttpServletRequest httpServletRequest) {
        if (!Webs.isOption(httpServletRequest)) {
            backuser = (Backuser) httpServletRequest.getAttribute("tokenInfo");
            if (backuser != null && customConfig.isDebug()) {
                log.info(" 用户信息：{}", backuser);
            }
        }

    }

}
